import com.gl.multipleyes.User
import com.gl.multipleyes.security.SecRole
import com.gl.multipleyes.security.SecUser
import com.gl.multipleyes.security.SecUserSecRole

class BootStrap {

    def init = { servletContext ->
		
		def admin = SecUser.findByUsername("superadmin")?:new SecUser(username: "superadmin",password:"test123",accountExpired:false,accountLocked:false,passwordExpired:false).save(flush:true, failOnError:true)
		def role = SecRole.findAllByAuthority("Administrator")?:new SecRole(authority:"Administrator").save(flush:true, failOnError:true)
		def roleAdmin = SecUserSecRole.findBySecUserAndSecRole(admin,role)?:SecUserSecRole.create(admin, role, true)
		def user = User.findByName("Lord")?:new User(externalId: "1",externalToken:"asdasda213",name:"Lord").save(flush:true, failOnError:true)
    }
    def destroy = {
    }
}
